package com.lovo.school.frame;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JDialog;
import javax.swing.JFrame;

import com.lovo.common.model.DeptBean;
import com.lovo.common.model.EmpBean;
import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoComboBox;
import com.lovo.netCRM.component.LovoTitleLabel;
import com.lovo.netCRM.component.LovoTxt;
import com.lovo.netCRM.component.LovoTxtArea;


/**
 * 学校增加对话框
 * @author 白德柯
 *
 */
public class SchoolAddDialog extends JDialog{


	/**学校名称文本框*/
	private LovoTxt nameTxt = new LovoTxt("学校名称",40,90,this);
	/**校长文本框*/
	private LovoTxt leaderTxt = new LovoTxt("校长",300,90,this);
	/**学校地址文本框*/
	private LovoTxt addrTxt = new LovoTxt("学校地址",40,130,this);
	/**学生人数文本框*/
	private LovoTxt studentCountTxt = new LovoTxt("学生人数",300,130,this);
	/**联系电话文本框*/
	private LovoTxt phoneTxt = new LovoTxt("联系电话",40,170,this);
	/**IP地址文本框*/
	private LovoTxt ipTxt = new LovoTxt("IP地址",300,170,this);
	/**老师人数文本框*/
	private LovoTxt teacherCountTxt = new LovoTxt("老师人数",40,210,this);
	/**说明文本框*/
	private LovoTxtArea infoTxt = new LovoTxtArea("说明",300,210,120,100,this);
	/**负责部门下拉框*/
	private LovoComboBox<DeptBean> deptComboBox;
	/**负责人下拉框*/
	private LovoComboBox<EmpBean> empComboBox;
	/**学校主面板*/
	private SchoolPanel schoolPanel;
	/**城市id*/
	private int cityId;
	
	public SchoolAddDialog(JFrame jf,int cityId,SchoolPanel schoolPanel){
		super(jf,true);
		this.schoolPanel = schoolPanel;
		this.cityId = cityId;
		this.setLayout(null);
		this.setTitle("学校增加");
		this.init();
		
		Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
		int x = (int) screensize.getWidth() / 2 - 290;
		int y = (int) screensize.getHeight() / 2 - 240;
		this.setBounds(x, y, 580, 480);
		this.setVisible(true);
	}
	/**
	 * 初始化
	 *
	 */
	private void init(){
		LovoTitleLabel titleLabel = new LovoTitleLabel("学校增加",this);
		titleLabel.setLocation(220, titleLabel.getY());
		this.initComboBox();
		
		LovoButton addButton = new LovoButton(220,330,"添加","image/add.png",this);
		addButton.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				boolean isOk = add();
				if(isOk){
					SchoolAddDialog.this.dispose();
				}
			}});
		
	}
	
	//--------------------------------------------
	/**
	 * 初始化下拉框
	 *
	 */
	private void initComboBox(){
		//添加负责部门List集合
		this.deptComboBox = new LovoComboBox("负责部门",new ArrayList(),40,250,this);
		//添加负责人List集合
		this.empComboBox = new LovoComboBox("负责人",new ArrayList(),40,290,this);
	}

	/**
	 * 添加操作
	 *
	 */
	private boolean add(){
		return true;
	}

}
